package tree.bulid;

import tree.model.IModelTree;

import java.util.List;
import java.util.function.Function;

/**
 * Created by admin on 2019/1/25.
 */
public class ModelTreeBuilder<M extends IModelTree<M, Id>, Id> extends TreeBuilderBase<M> {
    public ModelTreeBuilder() {
    }
    @Override
    protected void addChild(M node, M child) {
        node.getChildren().add(child);
    }

    public M build(Id rootId, Function<M, M> toNode, List<M> list, Class<M> clazz) {
        return this.build(rootId, (m1, id) -> {
            m1.setId(id);
        }, (m2) -> {
            return m2.getId();
        }, (m3) -> {
            return m3.getParentId();
        }, toNode, list, clazz);
    }
}
